<html>
<head>
<script src="tqq.js"></script>
<script>

var check_interval = 3000;
var tqqurl = "http://t.qq.com";
var tqqaturl = "http://t.qq.com/at";

function init() 
{    
    var itv = new Number(localStorage['tqq_interval']);
    if (itv > 1000)
    {
        check_interval = itv;
    }
    check_at();
    window.setInterval(check_at, check_interval);
}

// Looks through all open tabs for Google Reader
function tabSearch(tabs) {
    for(var i in tabs) {
        var tab = tabs[i];
        if(tab.url.indexOf(tqqurl) >= 0) {
            chrome.tabs.update(tab.id, {selected:true});
            return;
        }
    }
    chrome.tabs.create({url:tqqaturl});
}

chrome.browserAction.onClicked.addListener(function(windowId) {
try{
    chrome.tabs.getAllInWindow(null, tabSearch);
}catch(e){alert(e);}
});

</script>
</head>
<body onload="init()">
</body>
</html>
